<?

	class clsGenerateMessage
	{
		function __construct()
		{
			
			$db_mysql = $GLOBALS['db_mysql'];
			
			$sql = " Select * From errors ";
			$generate_data_rows = $db_mysql->get_array($sql);
			if(count($generate_data_rows) > 0)
			{
				$file_content = array("en"=>"","fr"=>"","nl"=>""); 
				$file_content_php = array("en"=>"","fr"=>"","nl"=>""); 
				
				for($index = 0 ; $index < count($generate_data_rows) ; $index ++)
				{
					$name = $generate_data_rows[$index]["name"];
					foreach($file_content as $key=>$value)
					{
						$value_php = $file_content_php[$key];
						
						$value .= "\t var " . strtoupper( trim($name) ). " = '" . replace_for_javascript( $generate_data_rows[$index]["title_" . $key] ) . "';\n";
						$value_php .= "\t define('" .  strtoupper( $name ) . "', \"" . $generate_data_rows[$index]['title_' . $key] . "\" );\n ";
						
						$file_content[$key] = $value;
						$file_content_php[$key] = $value_php;
					}
				}
				$file_name_template = "js/validation";
				
				//save file js
				foreach($file_content as $key=>$value)
				{
					$file_name = $file_name_template . "_" . $key . ".js";
					$f = fopen($file_name, 'wb');
					if ($f) {
						fwrite($f, $file_content[$key]);
					}
					fclose($f);
				}
				$file_name_template = "includes/validation";
				//save file php
				foreach($file_content_php as $key=>$value)
				{
					$file_name = $file_name_template . "_" . $key . ".php";
					$f = fopen($file_name, 'wb');
					if ($f) {
						fwrite($f, "<? \n " . $file_content_php[$key] . " \n ?>");
					}
					fclose($f);
				}
			}
		}
	}

?>